#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <color.h>
#include <fcntl.h>
#include <sys/stat.h>

int getzphlength(char *path)
{
	struct stat file;
	stat(path,&file);
	return file.st_size;
}

int getnchr(char *string,char chr)
{
	int i,sum=0;
	for(i=0;i<strlen(string);i++){
		if(string[i]==chr)
			sum++;
	}
	return sum;
}


int lcosubstr(char *mainstr, char *substr)
{
	return(strlen(mainstr)-strspn(mainstr,substr)-1)
}


int strsw(char *mainstr, char *substr)
{
	int i;
	for(i=0;i<strlen(substr);i++){
		if(mainstr[i]!=substr[i])
			return 0;
	}
	return 1;
}

int getdbglevel(char *line)
{
	if(!(strsw(line,"debug")))
		return -1;
	int f=lcosubstr(line,"debug=")+1;
	char *strptr =line[f];
	if(strcmp(strptr,"yes")==0)
		return 1;
	else if(strcmp(strptr,"no")==0)
		return 0;
}
